// src/services/login.ts
import { BaseURL } from "@/stores/modules/base";
import type { LoginDTO, LoginResult, LoginResultUserVO } from "@/types/member";
import { http, httpR2 } from "@/utils/http";

type LoginParams = {
  code: string;
  encryptedData: string;
  iv: string;
};

/**
 * 小程序登录
 * @param code 请求参数，返回的唯一识别码
 */
export const postLoginWithWxCode = (code: string) => {
  return httpR2<LoginResultUserVO>({
    method: "POST",
    url: BaseURL + "/user/user/wxlogin",
    data: {
      code: code,
    },
  });
};

export const postLoginByAccountAndPassword = (loginMessage: LoginDTO) => {
  return httpR2<LoginResultUserVO>({
    method: "POST",
    url: BaseURL + "/user/user/login",
    data: {
      account: loginMessage.account,
      password: loginMessage.password,
    },
  });
};
